The present application relates generally to an improved data processing apparatus and method and more specifically to mechanisms for automatic use of large pages.
A page, memory page, or virtual page is a fixed-length contiguous block of virtual memory that is the smallest unit of data for memory allocation performed by the operating system for a program and transfer between main memory and any other auxiliary store, such as a hard disk drive. Virtual memory allows a page that does not currently reside in main memory to be addressed and used. If a program tries to access a location in such a page, an exception called a page fault is generated. The hardware or operating system is notified and loads the required page from the auxiliary store automatically. A program addressing the memory has no knowledge of a page fault or a process following it. Thus a program can address more (virtual) RAM than physically exists in the computer. A transfer of pages between main memory and an auxiliary store, such as a hard disk drive, is referred to as paging or swapping
Traditionally, pages in a system had uniform size, for example 4096 bytes. However, processor designs often allow two or more, sometimes simultaneous, page sizes due to the benefits and penalties. There are several points that can factor into choosing the best page size. When transferring from disk, much of the delay is caused by seek time, the time it takes to correctly position the read/write heads above the disk platters. Because of this, large sequential transfers are more efficient than several smaller transfers. Transferring the same amount of data from disk to memory often requires less time with larger pages than with smaller pages.
When two processes share a physical page, the processes may have two different virtual addresses to that page. Copy-on-write is an optimization strategy used in computer programming. The fundamental idea is that if multiple callers ask for resources that are initially indistinguishable, they can all be given pointers to the same resource. For instance, when two processes share a physical page of memory, the processes may have two different virtual addresses to the same physical page. This state of affairs can be maintained until a caller tries to modify its “copy” of the resource, at which point a separate (private) copy is made for that caller to prevent its changes from becoming visible to everyone else. All of this happens transparently to the callers. The primary advantage is that if no caller ever makes any modifications, no private copy need ever be created.
Large pages prohibit efficient demand paging because of all-or-nothing property of large pages. For 4 KB pages, copy-on-write and/or demand-based fetching is reasonable; however, for 1 GB pages, copy-on-write and/or demand-based fetching is not reasonable.